package jp.reflexworks.gae.blogger;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.http.*;

@SuppressWarnings("serial")
public class CategoryServlet extends HttpServlet {
	Logger logger = Logger.getLogger(this.getClass().getName());
	public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {		
		/*
		 * web.xmlは
		 * <url-pattern>/category/*</url-pattern>
		 * とすること
		 * <url-pattern>/category</url-pattern>
		 * だと404になってしまう
		 */
		//教材(study), 衣服(clothes), 家具(furniture)
		/*
			/study/keizai/keizaigakka/mon1/
			/study/keizai/keizaigakka/mon2/
			/study/keizai/keizaigakka/tue1/
			/study/keizai/kokusaigakka/mon1/
			/study/keizai/kokusaigakka/mon2/
			/study/keizai/kokusaigakka/mon3/
			/study/keizai/shougakka/mon1/
			/study/keizai/shougakka/mon2/
			/study/keizai/shougakka/mon3/
			/study/hougaku/houritsugakka/mon1/
			/study/hougaku/houritsugakka/mon2/
			/clothes/seifuku/zubon/
			/clothes/yshirts/vneck/
			/clothes/yshirts/turtle/
			/furniture/bed/
			/furniture/desk/round/
			/furniture/desk/rect/
		 */
		
		

		String category = req.getPathInfo();
		
		String json = "{\"category\":[";
		
		if (category.equals("/study/")) {
			json += "{\"/study/keizai/\":\"経済学部\"}," + 
					"{\"/study/hougaku/\":\"法学部\"}";
		} else if (category.equals("/study/keizai/")) {
			json += "{\"/study/keizai/keizaigakka/\":\"経済学科\"}," + 
					"{\"/study/keizai/kousaigakka/\":\"国際学科\"}";
			
		} else if (category.equals("/study/keizai/keizaigakka/")) {
			json += "{\"/study/keizai/keizaigakka/mon1/\":\"月曜1限\"}," + 
					"{\"/study/keizai/keizaigakka/mon2/\":\"月曜2限\"}," + 
					"{\"/study/keizai/keizaigakka/tue1/\":\"火曜1限\"}";
			
		} else if (category.equals("/study/keizai/kokusaigakka/")) {
			json += "{\"/study/keizai/keizaigakka/mon1/\":\"月曜1限\"}," + 
					"{\"/study/keizai/keizaigakka/mon2/\":\"月曜2限\"}," + 
					"{\"/study/keizai/keizaigakka/tue1/\":\"火曜1限\"}";
			
		} else if (category.equals("/study/hougaku/")) {
			json += "{\"/study/hougaku/houritsugakka/\":\"法律学科\"}";
			
		} else if (category.equals("/study/hougaku/houritsugakka/")) {
			json += "{\"/study/keizai/houritsugakka/mon3/\":\"月曜3限\"}," + 
					"{\"/study/keizai/houritsugakka/mon4/\":\"月曜4限\"}," + 
					"{\"/study/keizai/houritsugakka/tue2/\":\"火曜2限\"}";
		} else {
			
		}
		
		json += "]}";
		
		res.setContentType("text/plain; charset=UTF-8");
		res.getWriter().println(json);
		
		
	}
}
